package cn.itsource.article.service.impl;

import cn.itsource.article.domain.Comment;
import cn.itsource.article.mapper.CommentReoisitory;
import cn.itsource.article.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheEvict(cacheNames = "cache_article_typle",key = "'tree_article_type'")
public class CommentServiceImpl implements ICommentService {
    @Autowired
    private CommentReoisitory reoisitory;

    @Override
    public void save(Comment comment) {
        comment.setUserId(1L);
        comment.setNickname("我是傻逼");
        reoisitory.save(comment);
    }

    @Override
    public List<Comment> finByArticleId(Long articleId) {
        return reoisitory.findByArticleId(articleId);
    }

    @Override
    public void deleteByPrimaryKey(String id) {
        reoisitory.deleteById(id);
    }
}
